﻿using System.Collections.Generic;
using System.Threading.Tasks;
namespace Odyssey.Consul
{
    using Features;
    using Models;

    /// <summary>
    /// 权限控制
    /// </summary>
    public interface IACLs
    {
        /// <summary>
        /// 初始化
        /// </summary>
        /// <returns></returns>

        Task<ResultBootstrap> Bootstrap();

        /// <summary>
        /// 检查复制状态信息
        /// </summary>
        /// <param name="queryParameter"></param>
        /// <returns></returns>
        Task<ResultReplication> Replication(QueryParameter queryParameter = null);

        /// <summary>
        /// 创建ACL令牌
        /// </summary>
        /// <param name="arguLogin"></param>
        /// <returns></returns>
        Task<ResultLogin> Login(ArguLogin arguLogin);

        /// <summary>
        /// 注销ACL令牌
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        Task Logout(string token);

        #region Token
        /// <summary>
        /// 创建令牌
        /// </summary>
        /// <param name="arguToken"></param>
        /// <returns></returns>
        Task<ResultToken> TokenCreate(ArguToken arguToken);

        /// <summary>
        /// 读取令牌信息
        /// </summary>
        /// <param name="accessorID"></param>
        /// <returns></returns>
        Task<ResultToken> TokenRead(string accessorID);

        /// <summary>
        /// 读取令牌信息
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        Task<ResultToken> TokenReadSelf(string token);

        /// <summary>
        /// 更新令牌
        /// </summary>
        /// <param name="arguToken"></param>
        /// <returns></returns>
        Task<ResultToken> TokenUpdate(ArguToken arguToken);
        
        /// <summary>
        /// 删除令牌
        /// </summary>
        /// <param name="accessorID"></param>
        /// <returns></returns>
        Task<bool> TokenDelete(string accessorID);

        /// <summary>
        /// 克隆令牌
        /// </summary>
        /// <param name="arguToken"></param>
        /// <returns></returns>
        Task<ResultToken> TokenClone(ArguToken arguToken);

        /// <summary>
        /// 可用令牌列表
        /// </summary>
        /// <returns></returns>
        Task<List<ResultToken>> TokenList();

        #endregion

        #region Policy
        /// <summary>
        /// 创建策略
        /// </summary>
        /// <param name="arguPolicy"></param>
        /// <returns></returns>
        Task<ResultPolicy> PolicyCreate(ArguPolicy arguPolicy);

        /// <summary>
        /// 读取策略信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<ResultPolicy> PolicyRead(string id);

        /// <summary>
        /// 更新策略信息
        /// </summary>
        /// <param name="arguPolicy"></param>
        /// <returns></returns>
        Task<ResultPolicy> PolicyUpdate(ArguPolicy arguPolicy);

        /// <summary>
        /// 删除策略
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<bool> PolicyDelete(string id);

        /// <summary>
        /// 策略列表
        /// </summary>
        /// <returns></returns>
        Task<List<ResultPolicy>> PolicyList();
        #endregion

        #region Role
        /// <summary>
        /// 创建角色
        /// </summary>
        /// <param name="arguRole"></param>
        /// <returns></returns>
        Task<ResultRole> RoleCreate(ArguRole arguRole);

        /// <summary>
        /// 获取角色信息
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        Task<ResultRole> RoleRead(string id, string name);

        /// <summary>
        /// 更新角色信息
        /// </summary>
        /// <param name="arguRole"></param>
        /// <returns></returns>
        Task<ResultRole> RoleUpdate(ArguRole arguRole);

        /// <summary>
        /// 删除角色
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<bool> RoleDelete(string id);

        /// <summary>
        /// 角色列表
        /// </summary>
        /// <returns></returns>
        Task<List<ResultRole>> RoleList();
        #endregion

        #region Auth-Method
        /// <summary>
        /// 创建操作权限
        /// </summary>
        /// <param name="arguAuthMethod"></param>
        /// <returns></returns>
        Task<ResultAuthMethod> AuthMehotdCreate(ArguAuthMethod arguAuthMethod);

        /// <summary>
        /// 读取操作权限
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        Task<ResultAuthMethod> AuthMethodRead(string name);

        /// <summary>
        /// 更新操作权限
        /// </summary>
        /// <param name="arguAuthMethod"></param>
        /// <returns></returns>
        Task<ResultAuthMethod> AuthMethodUpdate(ArguAuthMethod arguAuthMethod);
        
        /// <summary>
        /// 删除操作权限
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        Task<bool> AuthMethodDelete(string name);

        /// <summary>
        /// 获取操作权限列表
        /// </summary>
        /// <returns></returns>
        Task<List<ResultAuthMethod>> AuthMethodList();
        #endregion

        #region Binding Rule
        /// <summary>
        /// 创建绑定规则
        /// </summary>
        /// <param name="arguBindingRule"></param>
        /// <returns></returns>
        Task<ResultBindingRule> BindingRuleCreate(ArguBindingRule arguBindingRule);

        /// <summary>
        /// 获取绑定规则信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<ResultBindingRule> BindingRuleRead(string id);

        /// <summary>
        /// 更新绑定规则
        /// </summary>
        /// <param name="arguBindingRule"></param>
        /// <returns></returns>
        Task<ResultBindingRule> BindingRuleUpdate(ArguBindingRule arguBindingRule);

        /// <summary>
        /// 删除绑定规则
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<bool> BindingRuleDelete(string id);

        /// <summary>
        /// 获取绑定规则列表
        /// </summary>
        /// <returns></returns>
        Task<List<ResultBindingRule>> BindingRuleList();
        #endregion
    }
}
